package com.dks.controller;

import com.dks.models.Department;
import com.dks.repository.IDepartmentRepository;
import com.dks.repository.IDepartmentRepository;
import com.dks.result.ResultModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("department")
public class DepartmentController {

    @Resource
    private IDepartmentRepository departmentRepository;


    @PostMapping("insert")
    public ResultModel<Boolean> insert(@RequestBody Department department) {
        return departmentRepository.insert(department);
    }

    @PostMapping("update")
    public ResultModel<Boolean> update(@RequestBody Department department) {
        return departmentRepository.update(department);
    }

    @PostMapping("delete")
    public ResultModel<Boolean> delete(@RequestBody Department department) {
        return departmentRepository.delete(department);
    }

    @GetMapping("select")
    public ResultModel<Boolean> select(@Param("id") Integer id) {
        return departmentRepository.select(id);
    }

    @GetMapping("getByMapList")
    public ResultModel<Boolean> getByMapList() {
        Map<String, Object> map = new HashMap<>();
        return departmentRepository.getByMapList(map);
    }


}
